home *** CD-ROM | disk | FTP | other *** search
/ Light ROM Gold / Light ROM Gold.iso / arexx / scenload.lwm < prev    next >
Text File  |  1995-09-04  |  5KB  |  205 lines

  1. /* CMD:Sceneload */
  2. /* Loads objects from Lightwave scene, maintains hierarchy */
  3. /* Brought to you by the Texas Chainsaw Massacre School of Programming */
  4. /* Kathy@cup.portal.com */
  5. /* Call the UNBORED BBS (908) 291-0126 */
  6. /* */
  7. /* */
  8. /* Note:To load objects deformed by Bones, you must use Save */
  9. /* Transformed in Layout. This macro will load the position, */
  10. /* rotation, size and pivot point changes of any object */
  11. /* including those with bones or displacement maps, but */
  12. /* not the Bone or Displacement map deformations themselves. */
  13. signal on error
  14. signal on syntax
  15. call addlib( "LWModelerARexx.port", 0 )
  16.  
  17. phile = GETFILENAME("Scene file to load as one object", "Toaster:Scenes" )
  18.   
  19.  if ~open('thisfile', phile, 'r') then do
  20.     call close('thisfile')
  21.     call notify(1,"!Say what? Something wrong with that filename. Load
  22.  aborted.")
  23.     exit
  24.     end
  25. /* This routine makes a list of the line numbers of the load object lines */
  26. /* Since different objects have different amounts of data lines */
  27. /* this keeps a record of where each object begins. Used to reference */
  28. /* info on parent objects */
  29.  momdad = 0
  30.  loadflag = 0
  31.  list = ""
  32.  parent = ""
  33.  point = ""
  34.  pivot = 0
  35. verzion = 0
  36. line = readln('thisfile')
  37. count = 1
  38. do while ~eof('thisfile')
  39.  parse var line first second
  40.  if first = "LoadObject" then do
  41.    list = list count
  42.   end
  43.  if first = "AddNullObject" then do 
  44.    list = list count
  45.    end
  46.  if first = "ParentObject" then do
  47.   parent = parent second
  48.   momdad = 1
  49.   end
  50.  if first = "ShowObject" then do
  51.    verzion = 1
  52.   end  
  53.  
  54.  if first = "PivotPoint" then do
  55.   point = point count
  56.   pivot = 1
  57.   end
  58.  if first = "ShadowOptions" then do 
  59.  if momdad = 0 then do 
  60.  parent = parent||"0"
  61.  end
  62.  if pivot = 0 then do
  63.  point = point||"0"
  64.  end
  65.  if verzion = 1 then
  66.   skipdown = 5
  67.   else 
  68.   skipdown = 4
  69.  
  70.  end
  71.  
  72. line = readln('thisfile')
  73. count = count +1
  74. end
  75. parent = strip(parent,'L',' ')
  76. list = strip(list,'L',' ')
  77. point =strip(point,'L',' ')
  78. call close('thisfile')
  79.  
  80.  
  81.  
  82. /* Part2 - Getting the objects and positioning them */
  83.  
  84.  if ~open('thisfile', phile, 'r') then do
  85.     call close('thisfile')
  86.     call notify(1,"say what?")
  87.     exit
  88.     end
  89.  
  90. /* read the first line in */
  91.  lion = readln('thisfile')
  92. dracula = 1 /* the Count */
  93. do while ~eof('thisfile')
  94. /* divide the line into 2 variables */ 
  95. /* when you get to a load object line, load the file */
  96. parse var lion furst sekond
  97.  if furst = "LoadObject" then do
  98.  
  99.  call setlayer(2)
  100.  sekond = strip(sekond,'L',' ')
  101.  relative = left(sekond,8)
  102.  if (relative = "OBJECTS/") then sekond = "Toaster:"sekond
  103.  if (relative = "Objects/") then sekond = "Toaster:"sekond
  104.  if (relative = "objects/") then  sekond = "Toaster:"sekond 
  105.  if ~open('fisle',sekond,'r') then do
  106.   call notify(1, '!Problem with the file name with scene file.')
  107.   call close('fisle')
  108.   exit
  109.   end
  110.   call close('fisle')
  111.    call load(sekond)
  112.   /* 5 lines down from the Load Object line is the position etc. info */
  113.    do  i = 1 to skipdown
  114.    lion = readln('thisfile')
  115.    end
  116.  /* Put the info into variables */    
  117.  parse var lion EX WHY ZEE H P B SX SY SZ
  118.   numba = dracula
  119.   call checkpoint()
  120.   dracula = dracula + 1
  121.  call transformations()
  122.  
  123.   lion = readln('thisfile')
  124.   parse var lion keyword argument
  125.     do until keyword = "ShadowOptions"
  126.     /* do until end of object section */
  127.     /* read lines from file */
  128.     
  129.     /* divide lines into 2 variables */
  130.     parse var lion ferst zekond
  131.     /* if you find a Parent Object line in an object section */
  132.        if ferst = "ParentObject" then do
  133.         call heritage()
  134.         /* check parent list to see if parent has parent */
  135.         nextparent = word(parent,zekond)
  136.          do while nextparent > 0 
  137.           
  138.           zekond = nextparent
  139.           call heritage()
  140.           nextparent = word(parent,zekond)
  141.           end
  142.         end 
  143.     lion =readln('thisfile')    
  144.      parse var lion keyword argument
  145.     end 
  146.  
  147.   call cut()
  148.   call setlayer(1)
  149.   call paste()
  150.   
  151.  end
  152.     
  153. lion = readln('thisfile')
  154. end
  155.     
  156.   
  157. exit
  158. heritage:
  159.     /* use the object number of the parent object to extract the line */
  160.     /* number of where that parent object's info begins */ 
  161.      linenumber = word(list,zekond)
  162.     /* add 5 to compute line of info */
  163.       linenumber = linenumber + skipdown
  164.     call flipthrough() 
  165.      /* pull the info from that line */  
  166.       parse var zip EX WHY ZEE H P B SX SY SZ
  167.   numba = zekond
  168.   call checkpoint()
  169.    call transformations()
  170.  
  171.  
  172. return 
  173. checkpoint:
  174.  /* extract line number of Pivot Point info */
  175.   linenumber = word(point,numba)
  176.      if linenumber > 0 then do
  177.      call flipthrough()
  178.       parse var zip DISCARD EXP WHYP ZEEP
  179.      /* move the pivot point */
  180.       call move((-EXP) (-WHYP) (-ZEEP))
  181.      end
  182.   return
  183.    
  184. flipthrough:
  185.     /* open another logical file */
  186.     /* read lines 'til you get to the one you want */
  187.       call open('fileagain',phile,'r')
  188.       do thumbthrough = 1 to linenumber
  189.       zip = readln('fileagain')
  190.       end
  191.       call close('fileagain')
  192.       
  193.  return
  194. transformations:
  195.   call MOVE(EX WHY ZEE)
  196.   call ROTATE(-B,Z,EX WHY ZEE)
  197.   call ROTATE(-P,X,EX WHY ZEE)
  198.   call ROTATE(-H,Y,EX WHY ZEE)
  199.  call SCALE(SX SY SZ, EX WHY ZEE) 
  200. return     
  201. syntax:
  202. error:
  203.    call end_all()
  204.    call notify( 1, "!Rexx Script Error", "@"errortext( rc ), "Line "sigl )
  205.    exit